<%--
  Created by IntelliJ IDEA.
  User: 甘汝雷
  Date: 2017/5/2
  Time: 14:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--解析表达式--%>
<%@ page isELIgnored="false" %>
<%--引入jstl--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--引入springMVC form--%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="page" uri="/xianzhiOA/pageTag" %>
<%@ taglib prefix="p" uri="/xianzhiOA/powerTag" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>工作量概况一览</title>
    <script type="application/javascript">
        function pToSub(page) {
            if(page!=undefined){
                var pageInp = document.getElementById("page");
                pageInp.value = page;
                var form = document.getElementById("scheduleForm");
                form.submit();
            }
        }
        window.onload = function () {
            if('${open}'=='1'){
                var weekOpen = document.getElementById("weekOpen");
                var workOpen = document.getElementById("workOpen");
                weekOpen.style.display = "none";
                workOpen.style.display = "block";
            }
        }
        function edit() {
            document.getElementById("weekForm").action = "${pageContext.request.contextPath}/Week/weekEdit.emp";
            document.getElementById("weekId").value = null;
            document.getElementById("weekForm").submit();
        }
        function deleteCheck(id) {
            if (confirm("确定要删除吗")) {
                window.location.href = "${pageContext.request.contextPath}/Week/deleteWeek.emp?weekId="+id;
            }
        }
    </script>
</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"></jsp:include>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"></jsp:include>
<div class="main">
    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="${pageContext.request.contextPath}/Login/goHomePage"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>基本信息</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>
    <sf:form id="weekForm" action="${pageContext.request.contextPath}/Week/selWeekAll.emp" modelAttribute="week" method="post" class="search1">
        <sf:input path="weekId" type="hidden"/>
        <input type="hidden" id="page" name="page" value="${page}"/>
        <input type="hidden" id="pages" name='pages' value="${pages}"/>
        <div style="height: 40px">
            <c:if test="${open==1}"><button type="submit" class="three btn btn-primary">返回</button></c:if>
            <p:power jspPower="工作量：添加">
            <button onclick="edit()" type="button" class="three btn btn-primary">添加</button>
            </p:power>
            <c:if test="${open!=1}"><a href="${pageContext.request.contextPath}/Week/selWeekAll.emp" class="three btn btn-primary">重置</a></c:if>
            <c:if test="${open==1}"><a href="${pageContext.request.contextPath}/Week/weekEdit.emp?weekId=${week1.weekId}" class="three btn btn-primary">修改</a></c:if></div>
        <c:if test="${open!=1}">归属项目<sf:input path="projectName"/>
        <c:if test="${userLogin.empRole.equals('1')}">负责人：<sf:input path="empName"/></c:if>
        所在周期：<sf:input style="width: 150px" path="weekString" type="test" class="sang_Calender"/>
        <button type="submit" class="one"><span class="fa fa-search"></span></button>
        </c:if>
    </sf:form>
    <c:if test="${weekList.isEmpty()}"><h3>您还没有填写该周期的工作量</h3></c:if>
    <c:if test="${!weekList.isEmpty()}">
    <div class="well" id="weekOpen">
        <table class="table">
            <thead>
            <tr>
                <th class="vv">所在周期</th>
                <th class="vv">归属项目</th>
                <c:if test="${userLogin.empRole.equals('1')}"><th class="vv">负责人</th></c:if>
                <th class="vv">计划（小时）</th>
                <th class="vv">实际（小时）</th>
                <th class="vv">偏差</th>
                <th class="vv">偏差率</th>
                <th class="vv">创建日期</th>
                <p:power jspPower="工作量：删除">
                    <th class="vv">删除</th>
                </p:power>
                <p:power jspPower="工作量：修改">
                    <th class="vv">修改</th>
                </p:power>
                <p:power jspPower="工作量：详情">
                    <th class="vv">详情</th>
                </p:power>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${weekList}" var="w">
            <tr>
                <td>${w.weekTimeBegin}<br/>${w.weekTimeEnd}</td>
                <td>${w.project.projectName}</td>
                <c:if test="${userLogin.empRole.equals('1')}"><td>${w.emp.empName}</td></c:if>
                <td>${w.weekPlan}小时</td>
                <td>${w.weekActual}小时</td>
                <td>${w.deviation}小时</td>
                <td>${w.rate}%</td>
                <td><fmt:formatDate value="${w.createTime}" pattern="yyyy-MM-dd" /></td>
                <p:power jspPower="工作量：删除">
                <td><a onclick="deleteCheck(${w.weekId})" role="button" data-toggle="modal"><i class="fa fa-times"></i></a></td>
                </p:power>
                <p:power jspPower="工作量：修改">
                <td><a href="${pageContext.request.contextPath}/Week/weekEdit.emp?weekId=${w.weekId}"><i class="fa fa-pencil"></i></a></td>
                </p:power>
                <p:power jspPower="工作量：详情">
                <td><a href="${pageContext.request.contextPath}/Week/selById.emp?weekId=${w.weekId}"
                       role="button" data-toggle="modal"><i class="fa fa-flag"></i></a></td>
                </p:power>
            </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    </c:if>
    <div class="well" id="workOpen" style="display: none">
             归属项目：${week1.project.projectName} 所在周期：${week1.weekTimeBegin}～${week1.weekTimeEnd}
        <c:if test="${userLogin.empRole.equals('1')}">负责人：${week1.emp.empName}</c:if>
            <table class="table">
                <thead>
                <tr>
                    <th class="vv">周</th>
                    <th class="vv">计划（小时）</th>
                    <th class="vv">实际（小时）</th>
                    <th class="vv">偏差</th>
                    <th class="vv">偏差率</th>
                    <th class="vv">创建日期</th>
                    ${week.weekId}
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${week1.workList}" var="i">
                    <tr>
                        <td>${i.workWeek}</td>
                        <td>${i.workPlan}小时</td>
                        <td>${i.workActual}小时</td>
                        <td>${i.deviation}小时</td>
                        <td>${i.rate}%</td>
                        <td><fmt:formatDate value="${i.createTime}" pattern="yyyy-MM-dd" /></td>
                    </tr>
                </c:forEach>
                <tr>
                    <th>合计</th>
                    <th>${week1.weekPlan}%</th>
                    <th>${week1.weekActual}%</th>
                    <th>${week1.deviation}%</th>
                    <th>${week1.rate}%</th>
                    <th></th>
                </tr>
                </tbody>
            </table>
    </div>
    <c:if test="${pages > 1}">
        <div style="float: right">
            <ul class="pagination">
                <page:paging length="10" page="${page}" pages="${pages}"/>
            </ul>
        </div>
    </c:if>
</div>
    <script type="text/javascript" src="${pageContext.request.contextPath}/dist/backEnd/js/datetime.js"></script>
</body>
</html>
